using System.Collections;
using UnityEngine;

public class DearMover : MonoBehaviour
{
	public float speed;

	public Animator[] dearMoversAnims;

	private bool isRun;

	private Vector3 prevPos;

	private void Start()
	{
		prevPos = base.transform.position;
	}

	private void FixedUpdate()
	{
		if (isRun != Vector3.Distance(base.transform.position, prevPos) / speed / Time.deltaTime > 0.1f)
		{
			float num = Vector3.Distance(base.transform.position, prevPos) / speed / Time.deltaTime;
			isRun = !isRun;
			for (int i = 0; i < dearMoversAnims.Length; i++)
			{
				StartCoroutine(ChangeMoveState(dearMoversAnims[i], isRun));
			}
		}
		prevPos = base.transform.position;
	}

	private IEnumerator ChangeMoveState(Animator animator, bool state)
	{
		if (state)
		{
			yield return new WaitForSeconds(Random.Range(0f, 0.7f));
		}
		animator.SetFloat("SpeedStraight", (!state) ? 0f : 1f);
	}
}
